#ifndef JLIB_GRAPHICS_MANAGERS_MOUSEMANAGER_H
#define JLIB_GRAPHICS_MANAGERS_MOUSEMANAGER_H

#include "../nodes/node.h"
#include "../event/mouse_event.h"

namespace jlib {


struct MouseManager : public Object {

  inline bool init () noexcept { return true; }

  void releaseNode (Node *node);

  void dispatchMove (Node *root, vec2 location);
  void dispatchDown (Node *root, int button, vec2 location);
  void dispatchUp (Node *root, int button, vec2 location);
  void dispatchLeave (Node *root);
  void dispatchScroll (Node *root, int scroll, vec2 location);

private:
  bool _dispatchMove (Node *node);
  bool _dispatchDown (Node *node);
  void _dispatchDrag (Node *node);
  bool _dispatchScroll (Node *node);

  MouseEvent _event;
  Objptr<Node> _focus;
  Objptr<Node> _tracker;
  int _tracked;
  bool _locked {false};

}; // struct MouseManager


} // namespace jlib

#endif // JLIB_GRAPHICS_MANAGERS_MOUSEMANAGER_H
